package com.tank.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.tank.bean.MailValid;
import com.tank.dao.MailDAO;

@Repository("mailDao")
public class MailDaoImpl extends TankDaoSupport implements MailDAO {

	public void save(MailValid mv) {
		this.getHibernateTemplate().save(mv);
	}

	public MailValid findByUUID(String uuid) {
		List<MailValid> ms = this.getHibernateTemplate().find(
				"from MailValid mv where mv.uuid='" + uuid + "'");

		if (ms != null && !ms.isEmpty())
			return ms.get(0);

		return null;
	}

	public MailValid findByIdAndUUID(Integer id, String uuid) {
		@SuppressWarnings("unchecked")
		List<MailValid> ms = this.getHibernateTemplate().find(
				"from MailValid mv where mv.id="+id+" and mv.uuid='" + uuid + "'");

		if (ms != null && !ms.isEmpty())
			return ms.get(0);
		return null;
	}

}
